{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Json_class(dict):\n",
    "    def  __init__(self, name):\n",
    "        self.update({\"name\":name})\n",
    "        return None                                ####初始化，只能返回None\n",
    "    def add_children(self,children):\n",
    "        \n",
    "            self.update({\"children\":children})\n",
    "            return self\n",
    "    def graph_viz(self,g):\n",
    "        g.node(self['name'])\n",
    "        try:\n",
    "            self['children']\n",
    "            if type(self['children'])==list:\n",
    "                [g.edge(self['name'],x['name']) for x in self['children'] ]\n",
    "                return [x.graph_viz(g) for x in  self['children']]\n",
    "            else:\n",
    "                g.edge(self['name'],self['children']['name'])\n",
    "\n",
    "                return self['children'].graph_viz(g)\n",
    "        except:\n",
    "            return g\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from graphviz import Digraph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "tom=Json_class(\"tom\")\n",
    "bob=Json_class(\"bob\")\n",
    "david=Json_class(\"david\")\n",
    "Ken=Json_class('Ken')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'name': 'tom', 'children': {'name': 'bob'}}"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tom.add_children(bob)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'name': 'bob', 'children': {'name': 'david'}}"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bob.add_children(david)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'name': 'david', 'children': {'name': 'Ken'}}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "david.add_children(Ken)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 12.2.1 (20241206.2353)\n",
       " -->\n",
       "<!-- Title: test_digraph Pages: 1 -->\n",
       "<svg width=\"71pt\" height=\"260pt\"\n",
       " viewBox=\"0.00 0.00 70.78 260.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 256)\">\n",
       "<title>test_digraph</title>\n",
       "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-256 66.78,-256 66.78,4 -4,4\"/>\n",
       "<!-- tom -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>tom</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"31.39\" cy=\"-234\" rx=\"27\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"31.39\" y=\"-228.95\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">tom</text>\n",
       "</g>\n",
       "<!-- bob -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>bob</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"31.39\" cy=\"-162\" rx=\"27\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"31.39\" y=\"-156.95\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">bob</text>\n",
       "</g>\n",
       "<!-- tom&#45;&gt;bob -->\n",
       "<g id=\"edge1\" class=\"edge\">\n",
       "<title>tom&#45;&gt;bob</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M31.39,-215.7C31.39,-208.41 31.39,-199.73 31.39,-191.54\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"34.89,-191.62 31.39,-181.62 27.89,-191.62 34.89,-191.62\"/>\n",
       "</g>\n",
       "<!-- david -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>david</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"31.39\" cy=\"-90\" rx=\"31.39\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"31.39\" y=\"-84.95\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">david</text>\n",
       "</g>\n",
       "<!-- bob&#45;&gt;david -->\n",
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>bob&#45;&gt;david</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M31.39,-143.7C31.39,-136.41 31.39,-127.73 31.39,-119.54\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"34.89,-119.62 31.39,-109.62 27.89,-119.62 34.89,-119.62\"/>\n",
       "</g>\n",
       "<!-- Ken -->\n",
       "<g id=\"node4\" class=\"node\">\n",
       "<title>Ken</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"31.39\" cy=\"-18\" rx=\"27\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"31.39\" y=\"-12.95\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">Ken</text>\n",
       "</g>\n",
       "<!-- david&#45;&gt;Ken -->\n",
       "<g id=\"edge3\" class=\"edge\">\n",
       "<title>david&#45;&gt;Ken</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M31.39,-71.7C31.39,-64.41 31.39,-55.73 31.39,-47.54\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"34.89,-47.62 31.39,-37.62 27.89,-47.62 34.89,-47.62\"/>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.graphs.Digraph at 0x257a3e09360>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "g = Digraph('test_digraph')\n",
    "tom.graph_viz(g)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'name': 'bob',\n",
       " 'children': [{'name': 'Ken'}, {'name': 'david', 'children': {'name': 'Ken'}}]}"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bob.add_children([Ken,david])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 12.2.1 (20241206.2353)\n",
       " -->\n",
       "<!-- Title: test_digraph Pages: 1 -->\n",
       "<svg width=\"96pt\" height=\"260pt\"\n",
       " viewBox=\"0.00 0.00 96.39 260.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 256)\">\n",
       "<title>test_digraph</title>\n",
       "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-256 92.39,-256 92.39,4 -4,4\"/>\n",
       "<!-- tom -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>tom</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"27\" cy=\"-234\" rx=\"27\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"27\" y=\"-228.95\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">tom</text>\n",
       "</g>\n",
       "<!-- bob -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>bob</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"27\" cy=\"-162\" rx=\"27\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"27\" y=\"-156.95\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">bob</text>\n",
       "</g>\n",
       "<!-- tom&#45;&gt;bob -->\n",
       "<g id=\"edge1\" class=\"edge\">\n",
       "<title>tom&#45;&gt;bob</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M27,-215.7C27,-208.41 27,-199.73 27,-191.54\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"30.5,-191.62 27,-181.62 23.5,-191.62 30.5,-191.62\"/>\n",
       "</g>\n",
       "<!-- Ken -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>Ken</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"27\" cy=\"-18\" rx=\"27\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"27\" y=\"-12.95\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">Ken</text>\n",
       "</g>\n",
       "<!-- bob&#45;&gt;Ken -->\n",
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>bob&#45;&gt;Ken</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M22.94,-143.93C20.69,-133.6 18.13,-120.12 17,-108 15.51,-92.07 15.51,-87.93 17,-72 17.76,-63.86 19.17,-55.1 20.69,-47.1\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"24.07,-48.05 22.64,-37.55 17.21,-46.65 24.07,-48.05\"/>\n",
       "</g>\n",
       "<!-- david -->\n",
       "<g id=\"node4\" class=\"node\">\n",
       "<title>david</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"57\" cy=\"-90\" rx=\"31.39\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"57\" y=\"-84.95\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">david</text>\n",
       "</g>\n",
       "<!-- bob&#45;&gt;david -->\n",
       "<g id=\"edge3\" class=\"edge\">\n",
       "<title>bob&#45;&gt;david</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M34.11,-144.41C37.42,-136.68 41.46,-127.27 45.21,-118.52\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"48.41,-119.92 49.14,-109.35 41.98,-117.16 48.41,-119.92\"/>\n",
       "</g>\n",
       "<!-- david&#45;&gt;Ken -->\n",
       "<g id=\"edge4\" class=\"edge\">\n",
       "<title>david&#45;&gt;Ken</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M49.74,-72.05C46.42,-64.32 42.41,-54.96 38.69,-46.27\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"41.95,-44.99 34.79,-37.18 35.51,-47.75 41.95,-44.99\"/>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.graphs.Digraph at 0x257a3e093c0>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "g = Digraph('test_digraph')\n",
    "tom.graph_viz(g)\n",
    "g"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'name': 'Ken', 'children': [{'name': 'morphy'}, {'name': 'bene'}]}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "morphy=Json_class(\"morphy\")\n",
    "bene=Json_class(\"bene\")\n",
    "Ken.add_children([morphy,bene])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'name': 'mao',\n",
       " 'children': [{'name': 'bob',\n",
       "   'children': [{'name': 'Ken',\n",
       "     'children': [{'name': 'morphy'}, {'name': 'bene'}]},\n",
       "    {'name': 'david',\n",
       "     'children': {'name': 'Ken',\n",
       "      'children': [{'name': 'morphy'}, {'name': 'bene'}]}}]},\n",
       "  {'name': 'david',\n",
       "   'children': {'name': 'Ken',\n",
       "    'children': [{'name': 'morphy'}, {'name': 'bene'}]}}]}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mao=Json_class('mao')\n",
    "mao.add_children([bob,david])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 12.2.1 (20241206.2353)\n",
       " -->\n",
       "<!-- Title: test_digraph Pages: 1 -->\n",
       "<svg width=\"173pt\" height=\"332pt\"\n",
       " viewBox=\"0.00 0.00 173.09 332.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 328)\">\n",
       "<title>test_digraph</title>\n",
       "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-328 169.09,-328 169.09,4 -4,4\"/>\n",
       "<!-- mao -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>mao</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"110.09\" cy=\"-306\" rx=\"27.3\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"110.09\" y=\"-300.95\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">mao</text>\n",
       "</g>\n",
       "<!-- bob -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>bob</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"138.09\" cy=\"-234\" rx=\"27\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"138.09\" y=\"-228.95\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">bob</text>\n",
       "</g>\n",
       "<!-- mao&#45;&gt;bob -->\n",
       "<g id=\"edge1\" class=\"edge\">\n",
       "<title>mao&#45;&gt;bob</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M116.73,-288.41C119.87,-280.57 123.69,-270.99 127.24,-262.13\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"130.48,-263.46 130.94,-252.88 123.98,-260.86 130.48,-263.46\"/>\n",
       "</g>\n",
       "<!-- david -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>david</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"83.09\" cy=\"-162\" rx=\"31.39\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"83.09\" y=\"-156.95\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">david</text>\n",
       "</g>\n",
       "<!-- mao&#45;&gt;david -->\n",
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>mao&#45;&gt;david</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M106.83,-287.87C102.27,-263.88 93.93,-219.99 88.45,-191.16\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"91.95,-190.85 86.64,-181.68 85.07,-192.15 91.95,-190.85\"/>\n",
       "</g>\n",
       "<!-- bob&#45;&gt;david -->\n",
       "<g id=\"edge4\" class=\"edge\">\n",
       "<title>bob&#45;&gt;david</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M125.89,-217.46C119.07,-208.8 110.43,-197.79 102.69,-187.95\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"105.51,-185.87 96.58,-180.17 100.01,-190.19 105.51,-185.87\"/>\n",
       "</g>\n",
       "<!-- Ken -->\n",
       "<g id=\"node4\" class=\"node\">\n",
       "<title>Ken</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"83.09\" cy=\"-90\" rx=\"27\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"83.09\" y=\"-84.95\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">Ken</text>\n",
       "</g>\n",
       "<!-- bob&#45;&gt;Ken -->\n",
       "<g id=\"edge3\" class=\"edge\">\n",
       "<title>bob&#45;&gt;Ken</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M137.59,-215.58C136.51,-197.12 133.2,-167.46 123.09,-144 118.54,-133.43 111.45,-123.04 104.49,-114.29\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"107.22,-112.09 98.1,-106.69 101.86,-116.59 107.22,-112.09\"/>\n",
       "</g>\n",
       "<!-- david&#45;&gt;Ken -->\n",
       "<g id=\"edge7\" class=\"edge\">\n",
       "<title>david&#45;&gt;Ken</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M77.21,-144.05C76.42,-136.57 76.17,-127.58 76.46,-119.14\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"79.94,-119.51 77.13,-109.3 72.96,-119.04 79.94,-119.51\"/>\n",
       "</g>\n",
       "<!-- david&#45;&gt;Ken -->\n",
       "<g id=\"edge10\" class=\"edge\">\n",
       "<title>david&#45;&gt;Ken</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M88.97,-144.05C89.76,-136.57 90.02,-127.58 89.72,-119.14\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"93.23,-119.04 89.06,-109.3 86.24,-119.51 93.23,-119.04\"/>\n",
       "</g>\n",
       "<!-- morphy -->\n",
       "<g id=\"node5\" class=\"node\">\n",
       "<title>morphy</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"40.09\" cy=\"-18\" rx=\"40.09\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"40.09\" y=\"-12.95\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">morphy</text>\n",
       "</g>\n",
       "<!-- Ken&#45;&gt;morphy -->\n",
       "<g id=\"edge5\" class=\"edge\">\n",
       "<title>Ken&#45;&gt;morphy</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M64.77,-76.49C57.19,-68.2 49.43,-56.99 43.86,-46.67\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"47.07,-45.27 39.58,-37.77 40.75,-48.3 47.07,-45.27\"/>\n",
       "</g>\n",
       "<!-- Ken&#45;&gt;morphy -->\n",
       "<g id=\"edge8\" class=\"edge\">\n",
       "<title>Ken&#45;&gt;morphy</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M73.12,-72.76C68.09,-64.58 61.87,-54.45 56.18,-45.2\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"59.32,-43.61 51.1,-36.92 53.35,-47.28 59.32,-43.61\"/>\n",
       "</g>\n",
       "<!-- Ken&#45;&gt;morphy -->\n",
       "<g id=\"edge11\" class=\"edge\">\n",
       "<title>Ken&#45;&gt;morphy</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M84.29,-71.7C80.73,-62.95 74.47,-52.21 67.51,-42.7\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"70.29,-40.58 61.33,-34.92 64.81,-44.93 70.29,-40.58\"/>\n",
       "</g>\n",
       "<!-- bene -->\n",
       "<g id=\"node6\" class=\"node\">\n",
       "<title>bene</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"126.09\" cy=\"-18\" rx=\"28.32\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"126.09\" y=\"-12.95\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">bene</text>\n",
       "</g>\n",
       "<!-- Ken&#45;&gt;bene -->\n",
       "<g id=\"edge6\" class=\"edge\">\n",
       "<title>Ken&#45;&gt;bene</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M81.89,-71.7C85.73,-62.27 92.7,-50.53 100.31,-40.52\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"102.76,-43.04 106.43,-33.1 97.37,-38.58 102.76,-43.04\"/>\n",
       "</g>\n",
       "<!-- Ken&#45;&gt;bene -->\n",
       "<g id=\"edge9\" class=\"edge\">\n",
       "<title>Ken&#45;&gt;bene</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M93.06,-72.76C98.17,-64.46 104.5,-54.15 110.25,-44.79\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"113.13,-46.79 115.38,-36.44 107.16,-43.13 113.13,-46.79\"/>\n",
       "</g>\n",
       "<!-- Ken&#45;&gt;bene -->\n",
       "<g id=\"edge12\" class=\"edge\">\n",
       "<title>Ken&#45;&gt;bene</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M101.41,-76.49C109,-68.2 116.75,-56.99 122.33,-46.67\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"125.43,-48.3 126.6,-37.77 119.12,-45.27 125.43,-48.3\"/>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.graphs.Digraph at 0x257a3e097b0>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "g = Digraph('test_digraph')\n",
    "mao.graph_viz(g)\n",
    "g"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "chain=[]\n",
    "for i in range(10):\n",
    "    name=str(i)\n",
    "    temp = Json_class(name)\n",
    "    chain.append(temp)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'name': '0'},\n",
       " {'name': '1'},\n",
       " {'name': '2'},\n",
       " {'name': '3'},\n",
       " {'name': '4'},\n",
       " {'name': '5'},\n",
       " {'name': '6'},\n",
       " {'name': '7'},\n",
       " {'name': '8'},\n",
       " {'name': '9'}]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chain"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "remote310",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.15"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
